<template>
	<view>
		<!-- <page-head :title="title"></page-head> -->
		<view class="uni-common-mt">
			<form @submit="saveData">
				<view class="uni-list">
					<view class="uni-list-cell">
						<view class="uni-list-cell-db">
							<view class="uni-label">产品编码</view>
						</view>
						<view class="uni-list-cell-db">
							<view class="uni-input">{{detailData.matnr}}</view>
						</view>
					</view>
					<view class="uni-list-cell" v-if="afs">
						<view class="uni-list-cell-db">
							<view class="uni-label">颜色尺码</view>
						</view>
						<view class="uni-list-cell-db">
							<view class="uni-input">{{detailData.colorName==null?'':detailData.colorName}} {{detailData.sizeName==null?'':detailData.sizeName}}</view>
						</view>
					</view>
					<view class="uni-list-cell">
						<view class="uni-list-cell-db">
							<view class="uni-label">订单数量</view>
						</view>
						<view class="uni-list-cell-db">
							<view class="uni-input">{{detailData.psmng}}</view>
						</view>
					</view>
					
					<!-- <view class="uni-list-cell">
						<view class="uni-list-cell-db">
							<view class="uni-label">完工数量</view>
						</view>
						<view class="uni-list-cell-db">
							<view class="uni-input">{{detailData.psmng}}</view>
						</view>
					</view> -->
					<view class="uni-list-cell">
						<view class="uni-list-cell-db">
							<view class="uni-label">工序</view>
						</view>
						<view class="uni-list-cell-db">
							<view class="uni-input">{{detailData.operationName}}</view>
						</view>
					</view>
				</view> 
				<view class="uni-list">
					<view class="uni-list-cell">
						<view class="uni-list-cell-db">
							<view class="uni-label">合格数</view>
						</view>
						<view class="uni-list-cell-db">
							<lc-number-box  :value="gmnga" :min="0" :disabled="false" :step="1" @change="gmngaChange"></lc-number-box>
						</view>
					</view>
					<view class="uni-list-cell">
						<view class="uni-list-cell-db">
							<view class="uni-label">不合格数</view>
						</view>
						<view class="uni-list-cell-db">
							<!-- <lc-number-box class="uni-input" :value="detailData.gamng" :min="1" :disabled="false" :step="1" @change=""></lc-number-box> -->
							<input class="uni-input" type="number" placeholder="" v-model="xmnga" name="remark"></input>
						</view>
					</view>
					
				
				</view>

				<view class="uni-padding-wrap" style="margin-top: 50upx;">
					<view class="uni-flex uni-row" >
						<button formType="submit" class="btn-save">提交</button>
						<!-- <button class="btn-del" @tap="delData">删除</button> -->
					</view>
				</view>
			</form>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import lcNumberBox from '@/components/lc-number-box/lc-numberBox.vue';
	export default {
		 components: {
		        lcNumberBox
		    },
		data() {
			return {
				detailData: [],
				gmnga:"",
				xmnga:0,
				afs: false
			};
		},
		onLoad(e) {
			this.detailData = JSON.parse(e.item); 
			if (uni.getStorageSync("industry") == 'afs') {
				this.afs = true
			}
			console.log(this.detailData)
		},
		methods: {
			gmngaChange(e) {
				this.gmnga=e;
			},
			saveData(e) {
				// if(this.indexGongxu==0){
				// 		this.$tip.alert('请选择工序');
				// 		return false
				// }
				if (this.gmnga == 0 && this.xmnga == 0) {
					uni.showToast({
						icon: 'none',
						title: '数量输入有误'
					});
					return;
				}
				
				let url = '/confirmation/confirmation/add'
				
				// let i = this.indexGongxu - 1;
				this.$http.post(url, {
						"aufnr": this.detailData.aufnr,
						"dispatchNo": this.detailData.dispatchNo,
						"matnr": this.detailData.matnr,
						"gmnga": this.gmnga,
						"xmnga": this.xmnga,
						"vornr": this.detailData.vornr,
						"color": this.detailData.color,
						"size": this.detailData.size
				},{emulateJSON:true}).then(res => {
					
					
					if (res.data.success) {
						console.log("success");
						if (res.statusCode == "200") {
								uni.showToast({
									// icon: 'none',
									title: '保存成功'
								});
								this.searchText = ""
								this.gmnga=0;
								this.xmnga=0;
						}
					}
				}).catch(err => {
					console.log(err);
				});
			}
				}
	 }
</script>

<style>
	.uni-list-cell:after {
		left: 20upx;
	}
	.uni-list-cell {
		height: 100upx;
	}
	.uni-input {
		text-align: right;
	}
	.uni-list {
		margin-bottom: 30upx;
	}
	.title {
		padding: 10px 0;
		width: 120px
	}
	
	.btn-save{
		background: #00aaff;
		color: #FFFFFF;
		width: 150px;
		/* display: inline-block; */
		/* max-width: none; */
	}
	.btn-del{
		background: #fa6b4b;
		color: #FFFFFF;
		width: 150px;
		/* display: inline-block; */
	}
	/* .btn-bottom{
		display: flex;
		padding:10upx 0;
		flex-direction: row;
	} */
	.uni-list-cell{
		padding-right: 20upx;
	}
</style>

